package com.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.EnableWebMvc;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.*;


@Configuration
@EnableWebMvc
public class MyMVCconfig implements WebMvcConfigurer {
    @Autowired
    private MyInterceptre myInterceptre;

    //添加拦截管理
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(myInterceptre)
                .addPathPatterns("/**")
                //不拦截登录，上传下载文件端口
                .excludePathPatterns("/ueUploadController/**","/admin/toLogin","/redirect/**",
                        "/back/index",
                        "/back/login","/toRegister","/register","/admin/login","/api/**",
                        "/delete/**","/update/**","/get/**","/toLogin","/login","/logout",
                        "/uploadFile","/download","/toUpload","/static/**")
                .excludePathPatterns("/login.html");
    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        //放开resource、static下的所有资源拦截
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/");
    }
}
